package org.tgcloud.group.web.controller.manager.project;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.custom.Permissions;
import org.tgcloud.group.core.session.Session;
import org.tgcloud.group.service.manager.project.ProjectMediaRequirementsManageService;
import org.tgcloud.group.web.controller.dto.project.IntendedMedia.ProjectIntendedMediaDTO;
import org.tgcloud.group.web.controller.dto.project.mediaRequirementsDTO.MediaRequirementsManageDTO;
import org.tgcloud.group.web.controller.manager.ManageAPPBaseController;
import org.tgcloud.group.web.controller.req.project.mediaRequirements.MediaRequirementsCreateReq;
import org.tgcloud.group.web.controller.req.project.mediaRequirements.MediaRequirementsPageReq;
import org.tgcloud.group.web.controller.req.project.mediaRequirements.MediaRequirementsUpdateReq;

/**
 * @Author: zhy
 * @Created: 2025-09-02-上午11:36
 * @Description:
 */
@Api(tags = "项目媒体需求管理相关接口")
@RestController
@RequestMapping("/manager/pc/user")
@EnableAutoConfiguration
public class ProjectMediaRequirementsManageController extends ManageAPPBaseController {

    @Autowired
    private ProjectMediaRequirementsManageService projectMediaRequirementsManageService;

    @Permissions("projectMediaRequirements:list")
    @ApiOperation(value = "项目媒体需求列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string"),
    })
    @ResponseBody
    @RequestMapping(value = "/getProjectMediaRequirementsList", method = RequestMethod.POST)
    public APPResultMessage<Object, MediaRequirementsManageDTO> getProjectMediaRequirementsList(@ModelAttribute("session") Session session,
                                                                                                @RequestBody MediaRequirementsPageReq req) {
        return projectMediaRequirementsManageService.getProjectMediaRequirementsList(req.getPageNum(),req.getPageSize(), req.getProjectId(), req.getStatus());
    }

    @Permissions("projectMediaRequirements:add")
    @ApiOperation(value = "添加项目媒体需求")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string"),
    })
    @ResponseBody
    @RequestMapping(value = "/addProjectMediaRequirements", method = RequestMethod.POST)
    public APPResultMessage doAddProjectMediaRequirements(@ModelAttribute("session") Session session,
                                                          @RequestBody MediaRequirementsCreateReq req) {
        return projectMediaRequirementsManageService.doAddProjectMediaRequirements(req);
    }



    @Permissions("projectMediaRequirements:update")
    @ApiOperation(value = "修改项目媒体需求")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string"),
    })
    @ResponseBody
    @RequestMapping(value = "/updateProjectMediaRequirements", method = RequestMethod.POST)
    public APPResultMessage doUpdateProjectMediaRequirements(@ModelAttribute("session") Session session,
                                                          @RequestBody MediaRequirementsUpdateReq req) {
        return projectMediaRequirementsManageService.doUpdateProjectMediaRequirements(req, session.getUserId(), session.getUserType());
    }

    @ApiOperation(value = "获取详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string"),
    })
    @ResponseBody
    @RequestMapping(value = "/getProjectMediaRequirementsDetails", method = RequestMethod.POST)
    public APPResultMessage<Object, MediaRequirementsManageDTO> getProjectMediaRequirementsDetails(@ModelAttribute("session") Session session,
                                                                                                @RequestParam Integer id) {
        return projectMediaRequirementsManageService.getProjectMediaRequirements(id);
    }



}
